package com.sjtu.vfact.textual.view;

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.border.CompoundBorder;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.BevelBorder;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

import com.sjtu.vfact.textual.util.ScrollablePanel;
import com.sjtu.vfact.textual.util.ScrollablePanel.ScrollableSizeHint;

public class MainFrameFullScreen {

	private JFrame frame;
	private JTable tableUncoveredTerms;
	private JTable tableMasterTermset;
	private JTable tableSummarizerSummary;
	private JTable tableEnumeratorSummary;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainFrameFullScreen window = new MainFrameFullScreen();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public MainFrameFullScreen() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
//		frame.setExtendedState(Frame.MAXIMIZED_BOTH);
		frame.setBounds(75, 75, 1000, 700);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(new BorderLayout(0, 0));
		
		JPanel panelUp = new JPanel();
		frame.getContentPane().add(panelUp, BorderLayout.NORTH);
		
		JPanel panelBottom = new JPanel();
		frame.getContentPane().add(panelBottom, BorderLayout.SOUTH);
		
		JPanel panelLeft = new JPanel();
		frame.getContentPane().add(panelLeft, BorderLayout.WEST);
		
		JPanel panelRight = new JPanel();
		frame.getContentPane().add(panelRight, BorderLayout.EAST);
		
		JPanel panelCenter = new JPanel();
		frame.getContentPane().add(panelCenter, BorderLayout.CENTER);
		panelCenter.setLayout(new BorderLayout(0, 0));
		
		JPanel panelCenterRight = new JPanel();
		panelCenterRight.setPreferredSize(new Dimension(300, 700));
		panelCenter.add(panelCenterRight, BorderLayout.EAST);
//		panelCenterRight.setLayout(new BorderLayout(0, 0));
		panelCenterRight.setLayout(new GridBagLayout());
		
		GridBagConstraints c = new GridBagConstraints();
		
//		JPanel panelMasterCollectionQuaInsp = new JPanel();
//		panelMasterCollectionQuaInsp.setPreferredSize(new Dimension(10, 365));
//		panelCenterRight.add(panelMasterCollectionQuaInsp, BorderLayout.NORTH);
//		panelMasterCollectionQuaInsp.setLayout(null);
		
		c.gridx = 0;
		c.gridy = 0;
		c.fill = GridBagConstraints.HORIZONTAL;
		c.ipadx = 100;
		c.ipady = 50;
		JPanel panelMasterCollection = new JPanel(new GridLayout(4,2));
		panelMasterCollection.setBorder(new CompoundBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Master Collection", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)), new BevelBorder(BevelBorder.LOWERED, null, null, null, null)));
//		panelMasterCollection.setBounds(6, 6, 386, 201);
//		panelMasterCollectionQuaInsp.add(panelMasterCollection);
//		panelMasterCollection.setPreferredSize(new Dimension(300, 400));
		JLabel lblFileName = new JLabel("File Name : ");
		JTextField txtFLdFileName = new JTextField();
		JLabel lblStatus = new JLabel("Status : ");
		JLabel lblStatusUpdate = new JLabel("Status Update");
		JLabel lblLength = new JLabel("Length(L) : ");
		JTextField txtFldLength = new JTextField();
		JLabel lblNumber = new JLabel("Number(N) : ");
		JTextField txtFldNumber = new JTextField();
		panelMasterCollection.add(lblFileName);
		panelMasterCollection.add(txtFLdFileName);
		panelMasterCollection.add(lblStatus);
		panelMasterCollection.add(lblStatusUpdate);
		panelMasterCollection.add(lblLength);
		panelMasterCollection.add(txtFldLength);
		panelMasterCollection.add(lblNumber);
		panelMasterCollection.add(txtFldNumber);
		
		
		panelCenterRight.add(panelMasterCollection, c);
		
		c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 1;
		c.ipadx = 100;
		c.ipady = 30;
		JPanel panelQualityInspector = new JPanel(new GridLayout(4,2));
		panelQualityInspector.setBorder(new CompoundBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Quality Inspector", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)), new BevelBorder(BevelBorder.LOWERED, null, null, null, null)));
		panelQualityInspector.setBounds(6, 213, 386, 146);
		
		JLabel lblFileName1 = new JLabel("File Name : ");
		JTextField txtFLdFileName1 = new JTextField();
		JLabel lblStatus1 = new JLabel("Status : ");
		JLabel lblStatusUpdate1 = new JLabel("Status Update");
		JLabel lblLength1 = new JLabel("Length(L) : ");
		JTextField txtFldLength1 = new JTextField();
		
		panelQualityInspector.add(lblFileName1);
		panelQualityInspector.add(txtFLdFileName1);
		panelQualityInspector.add(lblStatus1);
		panelQualityInspector.add(lblStatusUpdate1);
		panelQualityInspector.add(lblLength1);
		panelQualityInspector.add(txtFldLength1);
		
		
//		panelMasterCollectionQuaInsp.add(panelQualityInspector);
		panelCenterRight.add(panelQualityInspector, c);
		
		
		
//		JPanel panelUncoverTermTable = new JPanel();
//		panelUncoverTermTable.setPreferredSize(new Dimension(10, 365));
//		panelCenterRight.add(panelUncoverTermTable, BorderLayout.SOUTH);
//		panelUncoverTermTable.setLayout(null);
		
		c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 2;
		c.ipadx = 100;
		c.ipady = 20;
		JPanel panelAMT = new JPanel(new GridLayout(2,2));
		panelAMT.setBorder(new CompoundBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "After Mining Task", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)), new BevelBorder(BevelBorder.LOWERED, null, null, null, null)));
		panelAMT.setBounds(6, 6, 386, 68);
//		panelUncoverTermTable.add(panelAMT);
		
		JLabel lblLength2 = new JLabel("Length(L) : ");
		JTextField txtFldLength2 = new JTextField();
		JLabel lblNumber2 = new JLabel("Number(N) : ");
		JTextField txtFldNumber2 = new JTextField();
		panelAMT.add(lblLength2);
		panelAMT.add(txtFldLength2);
		panelAMT.add(lblNumber2);
		panelAMT.add(txtFldNumber2);
		
		panelCenterRight.add(panelAMT, c);
		
//		ScrollablePanel panelUncoveredTerms = new ScrollablePanel();
//		panelUncoveredTerms.setBounds(6, 86, 386, 273);
//		panelUncoverTermTable.add(panelUncoveredTerms);
//		
//		JScrollPane scrollPaneUncoveredTerms = new JScrollPane();
//		scrollPaneUncoveredTerms.setPreferredSize(new Dimension(375, 263));
//		panelUncoveredTerms.add(scrollPaneUncoveredTerms);
		
		c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 3;
		c.ipadx = 100;
		c.ipady = 50;
		ScrollablePanel panelUncoveredTermsTable = new ScrollablePanel(new GridLayout(4,2));
		panelUncoveredTermsTable.setScrollableWidth(ScrollableSizeHint.STRETCH);
		panelUncoveredTermsTable.setScrollableHeight(ScrollableSizeHint.STRETCH);
//		
//		Object[] columns4 = {"No", "Uncovered Terms", "Support", "DocIDs"};
//		Object[][] data4 = {{1, "hello, world", 5, "(1, 2)"},{2, "hello Indonesia", 8, "(3,4)"}};
//		tableUncoveredTerms = new JTable(data4, columns4);
//		
//		JScrollPane spUncoveredTermsTable = new JScrollPane(tableUncoveredTerms);
////		spUncoveredTermsTable.setPreferredSize(new Dimension(800, 230));
//		panelUncoveredTermsTable.add(spUncoveredTermsTable);
//		
		JScrollPane spUncoveredTerms = new JScrollPane(panelUncoveredTermsTable);
//		
		
		JLabel lblFileName3 = new JLabel("File Name : ");
		JTextField txtFLdFileName3 = new JTextField();
		JLabel lblStatus3 = new JLabel("Status : ");
		JLabel lblStatusUpdate3 = new JLabel("Status Update");
		JLabel lblLength3 = new JLabel("Length(L) : ");
		JTextField txtFldLength3 = new JTextField();
		JLabel lblNumber3 = new JLabel("Number(N) : ");
		JTextField txtFldNumber3 = new JTextField();
		panelUncoveredTermsTable.add(lblFileName3);
		panelUncoveredTermsTable.add(txtFLdFileName3);
		panelUncoveredTermsTable.add(lblStatus3);
		panelUncoveredTermsTable.add(lblStatusUpdate3);
		panelUncoveredTermsTable.add(lblLength3);
		panelUncoveredTermsTable.add(txtFldLength3);
		panelUncoveredTermsTable.add(lblNumber3);
		panelUncoveredTermsTable.add(txtFldNumber3);
		
		panelCenterRight.add(spUncoveredTerms, c);
		
		
//		scrollPaneUncoveredTerms.setViewportView(tableUncoveredTerms);
		
		
		//Left Panel of Frame
		JPanel panelCenterCenter = new JPanel();
		panelCenter.add(panelCenterCenter, BorderLayout.CENTER);
		panelCenterCenter.setLayout(new GridLayout(3, 1));
		
		//Create and Set Position of Master Termset Table
		ScrollablePanel panelMasterTermsetTable = new ScrollablePanel();
		panelMasterTermsetTable.setScrollableWidth(ScrollableSizeHint.STRETCH);
		panelMasterTermsetTable.setScrollableHeight(ScrollableSizeHint.STRETCH);
		
		Object[] columns1 = {"No", "Master Termsets", "Support", "DocIDs"};
		Object[][] data1 = {{1, "hello, world", 5, "(1, 2)"},{2, "hello Indonesia", 8, "(3,4)"}};
		tableMasterTermset = new JTable(data1, columns1);
//		tableMasterTermset.setFillsViewportHeight(false);
		JScrollPane spMasterTermsetTable = new JScrollPane(tableMasterTermset); 
		spMasterTermsetTable.setPreferredSize(new Dimension(800, 230));
		panelMasterTermsetTable.add(spMasterTermsetTable);

		JScrollPane scrollPaneMasterTermset = new JScrollPane(panelMasterTermsetTable);
		panelCenterCenter.add(scrollPaneMasterTermset);
		
		//Create and Set Position of Summarizer Summary Table
		ScrollablePanel panelSummarizerSummaryTable = new ScrollablePanel();
		panelSummarizerSummaryTable.setScrollableWidth(ScrollableSizeHint.STRETCH);
		panelSummarizerSummaryTable.setScrollableHeight(ScrollableSizeHint.STRETCH);
		
		Object[] columns2 = {"No", "Summarizer's Summary", "Support", "DocIDs"};
		Object[][] data2 = {{1, "hello, world", 5, "(1, 2)"},{2, "hello Indonesia", 8, "(3,4)"}};
		tableSummarizerSummary = new JTable(data2, columns2);
		
		JScrollPane spSummarizerTable = new JScrollPane(tableSummarizerSummary); 
		spSummarizerTable.setPreferredSize(new Dimension(800, 230));
		panelSummarizerSummaryTable.add(spSummarizerTable);
		
		JScrollPane spSummarizer = new JScrollPane(panelSummarizerSummaryTable);
		panelCenterCenter.add(spSummarizer);
		
		//Create and Set Position of Enumerator Summary Table
		ScrollablePanel panelEnumeratorSummaryTable = new ScrollablePanel();
		panelEnumeratorSummaryTable.setScrollableWidth(ScrollableSizeHint.STRETCH);
		panelEnumeratorSummaryTable.setScrollableHeight(ScrollableSizeHint.STRETCH);
		
		Object[] columns3 = {"No", "Enumerator's Summary", "Support", "DocIDs"};
		Object[][] data3 = {{1, "hello, world", 5, "(1, 2)"},{2, "hello Indonesia", 8, "(3,4)"}};
		tableEnumeratorSummary = new JTable(data3, columns3);
		
		JScrollPane spEnumeratorTable = new JScrollPane(tableEnumeratorSummary);
		spEnumeratorTable.setPreferredSize(new Dimension(800, 230));
		panelEnumeratorSummaryTable.add(spEnumeratorTable);
		
		JScrollPane spEnumerator = new JScrollPane(panelEnumeratorSummaryTable);
		panelCenterCenter.add(spEnumerator);
		
	}
}
